package reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class reflectDemo6 {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        Class cls = Class.forName("reflect.Person");
        Object o = cls.newInstance();
        Method method = cls.getDeclaredMethod("hehe");
        method.setAccessible(true);//强行设置为可访问
        method.invoke(o);

    }
}
